package com.situ.day11;

import java.lang.reflect.Array;

import org.junit.Test;

public class LianXi {
	@Test
	public void test(){
		String str = "--Java Android--";
		String trimStr = trim(str);
		System.out.println(trimStr);
	}

	private String trim(String str) {
		int start = 0;
		int end = str.length() - 1;
		while (str.charAt(start) == '-' ){
			start++;
		}
		while(str.charAt(end) == '-'){
			end--;
		}
		return str.substring(start,end + 1);
	}
	@Test
	public void test2() {
		String str = "I LOVE JAVA!";
		char[]arr = str.toCharArray();
		for (int i = 0; i < arr.length; i++) {
			if (arr[i] >= 'A' && arr[i] <= 'Z') {
				arr[i] = (char) (arr[i] + 32);
			}
		}
		String s = new String(arr);
		System.out.println(s);
	}
	
	@Test
	public void test3() {
		String str = "this is my homework!"
				+ " I must finish it!";	
		String[] arr = str.split(" ");
		System.out.println(arr.length);
	}
	
	@Test
	public void test4() {
		String str1 = "hello";
		String str2 = "java";
		String str3 = "Android";
		String str4 = "IOS";
		
		StringBuilder builder = new StringBuilder();
		builder.append(str1);//追加
		builder.append(str2);
		builder.append(str3);
		System.out.println(builder);
		
		//链式编程
		StringBuilder builder1 = new StringBuilder(str1);
		builder1.append(str2).append(str3).append(str4);
		System.out.println(builder1);
	}
	

	
	
}
 